package com.hgsoft.yfzx.component.runninglog.web.controller;

import com.hgsoft.yfzx.webapp.base.BaseController;
import com.hgsoft.yfzx.webapp.security.entity.SysUser;
import com.hgsoft.yfzx.webapp.security.service.UserService;
import com.hgsoft.yfzx.webapp.security.util.ShiroUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.messaging.simp.SimpMessagingTemplate;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.Collections;
import java.util.List;

/**
 * @author Sawyerlsy
 * @Date 2018年12月29日
 */
@Controller
@RequestMapping("/log")
public class LogController extends BaseController {

    @Autowired
    private SimpMessagingTemplate messagingTemplate;

    @Autowired
    private UserService userService;

    /**
     * 跳转到运行日志页面
     */
    @GetMapping("/runninglog")
    public String index(Model model) {
        List<SysUser> userList = userService.findAllUser();

        //为了方便接口调试这里手动增加匿名用户
        if (null == userList) {
            userList = Collections.emptyList();
        }

        model.addAttribute("userList", userList);
        model.addAttribute("currentUser", ShiroUtil.currentOperator());
        return "runningLog/runningLog";
    }
}
